package com.example.myapplication.moudule.home.presenter;

import com.example.myapplication.base.mvp.BasePresenter;
import com.example.myapplication.base.DataResult;
import com.example.myapplication.base.network.rxJava.CustomizesObserver;
import com.example.myapplication.moudule.home.iview.IHomeView;
import com.example.myapplication.moudule.home.repository.HomeRepository;
import com.example.myapplication.moudule.home.repository.response.HomePageData;
import com.example.myapplication.utils.LogUtils;

public class HomePresenter extends BasePresenter<IHomeView> {
    private HomeRepository homeModel;


    @Override
    public void oncreate() {
        super.oncreate();
        homeModel=new HomeRepository();

    }

    public void getHomeData(){
        showLoading(true);
        homeModel.optHomePage("")
                .subscribe(new CustomizesObserver<DataResult<HomePageData>>(this) {
                    @Override
                    public void onNext(DataResult<HomePageData> homePageDataDataResult) {
                        if(getView()!=null){
                            getView().optHomePageDataSuccess(homePageDataDataResult.getData());
                        }

                        LogUtils.info("htd",homePageDataDataResult.getData().list.get(0).title);
                    }
                });
    }
}
